package basic.socket.udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

/**
 * @author bingo
 * @Description
 * @Date 2018/7/18
 */
public class DatagramSocketClient {

    public static void main(String[] args) throws Exception {

        try {
            DatagramSocket ds = new DatagramSocket();

            byte[] data = "hello i am coming".getBytes();

            System.out.println("data.length"+data.length);

            DatagramPacket dp = new DatagramPacket(data,data.length, InetAddress.getByName("127.0.0.1"),8888);

            ds.send(dp);

            ds.close();


        } catch (SocketException e) {
            e.printStackTrace();
        }

    }
}
